﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using HellCook.WinApp_WPF.RecipeManager;
using System.Collections.ObjectModel;
using HellCook.Model;

namespace HellCook.WinApp_WPF
{
    /// <summary>
    /// Interaction logic for AddNewRecipe.xaml
    /// </summary>
    public partial class AddNewRecipe : Window
    {
        Collection<NodoCantidadIngrediente> ListIngredient;

        public AddNewRecipe()
        {
            InitializeComponent();

            ListIngredient = new Collection<NodoCantidadIngrediente>();
        }

        public AddNewRecipe(string nombreReceta)
        {
            InitializeComponent();

            ListIngredient = new Collection<NodoCantidadIngrediente>();

            this.textBox_NameRecipe.Text = nombreReceta;
            this.textBox_NameRecipe.IsEnabled = false;
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            AddIngredientQuantity AddList = new AddIngredientQuantity(this.ListIngredient, this.dataGrid_LisIngredients);
            AddList.ShowDialog();
        }

        private void button2_Click(object sender, RoutedEventArgs e)
        {
            int Selected = this.dataGrid_LisIngredients.SelectedIndex;
            if ( Selected != -1 && Selected < this.ListIngredient.Count)
            {
                this.ListIngredient.RemoveAt(Selected);
                this.dataGrid_LisIngredients.ItemsSource = null;
                this.dataGrid_LisIngredients.ItemsSource = this.ListIngredient;
            }
        }

        private void button4_Click(object sender, RoutedEventArgs e)
        {
            this.Close();
        }

        private void button3_Click(object sender, RoutedEventArgs e)
        {
            string Message = HellCook.Business.Receta_Registro.NuevaReceta(this.textBox_NameRecipe.Text, this.textBox_Description.Text, this.ListIngredient);
            MessageBox.Show(Message, "Mensaje");
            this.Close();
        }
    }
}
